<%--
  Created by IntelliJ IDEA.
  User: bwj
  Date: 2021/6/23
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>
        车票修改
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">

</head>

<body>
<div class="x-body">

    <xblock>
        <button class="layui-btn" >
            车票修改
        </button>
    </xblock>
    <form action="" method="" id="update_ticket">
        <input type="hidden"  name="ticketId" id="ticketId" value="${ticket.ticketId}" />
        订单ID：<input name="orderId" id="orderId"  type="text" value="${ticket.order.orderId}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        创建时间：<input name="createdTime" id="createdTime"  type="text" value="${ticket.order.createdTime}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        支付时间:   <input name="paidTime" id="paidTime"  type="text" value="${ticket.order.paidTime}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        乘客:   <input name="passengerName" id="passengerName"  type="text" value="${ticket.passenger.passengerName}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        证件号：    <input name="idNumber" id="idNumber"  type="text" value="${ticket.passenger.idNumber}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        证件类型：<input name="idNumbertype" id="idNumbertype"  type="text" value="${ticket.passenger.idType.typeName}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        乘客类型：    <input name="documentTyp" id="documentTyp"  type="text" value="${ticket.passenger.documentTyp.typeName}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        列车类型：<input name="trainType" id="trainType"  type="text" value="${ticket.order.trainNumber.train.trainType.typeName}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        车名： <input name="trainName" id="trainName"  type="text" value="${ticket.order.trainNumber.train.trainName}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        发车日期：<input name="departureDate" id="departureDate" disabled="disabled"  type="text" value="${ticket.order.departureDate}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        发车时间：<input name="departureTime" id="departureTime" disabled="disabled"  type="text" value="${ticket.order.departureTime}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        出发站：<input name="startingStation" id="startingStation" disabled="disabled"  type="text" value="${ticket.order.startingStation.siteName}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        终点站： <input name="terminalStation" id="terminalStation"  type="text" value="${ticket.order.terminalStation.siteName}" disabled="disabled" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        车厢类型：<input name="carType" id="carType" disabled="disabled"  type="text" value="${ticket.carriage.carInfoId.carType.typeName}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        座位车号：<input name="carNumber" id="carNumber" disabled="disabled"  type="text" value="${ticket.seat.initialSeat.carNumber}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        座位行号：<input name="row" id="row" disabled="disabled"  type="text" value="${ticket.seat.initialSeat.srow}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        座位列号：<input name="col" id="col" disabled="disabled"  type="text" value="${ticket.seat.initialSeat.scol}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        票价：<input name="price" id="price" disabled="disabled"  type="text" value="${ticket.price}" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        订单状态：<select class="form-control" id="ticketType.typeId"
                name="ticketType.typeId">
            <option value="${ticket.ticketType.typeId}">
                ${ticket.ticketType.typeName}
            </option>
            <c:forEach items="${chepiaoList}" var="c">
                <option value="${c.typeId}">
                    ${c.typeName }
                </option>
            </c:forEach>
        </select>
        <hr class="hr15">

        <div align="center">  <button class="layui-btn" type="button" id="" lay-filter="add" lay-submit="">
            保存
        </button></div>

    </form>

    <div id="page"></div>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        okLoading.close($);
        //以上模块根据需要引入


        var start = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };

        document.getElementById('LAY_demorange_s').onclick = function(){
            start.elem = this;
            laydate(start);
        }
        document.getElementById('LAY_demorange_e').onclick = function(){
            end.elem = this
            laydate(end);
        }
    });


</script>

<script>
    var add=document.getElementById('ches');
    var inputs=add.getElementsByTagName('input');

    /*$("allSelect").onclick = function () {
        for(var i=0; i<inputs.length; i++){
            inputs[i].checked = true;
        }
    };*/
    var che=document.getElementById("onclicks");
    che.addEventListener('click',function () {
        for(var i=0; i<inputs.length;i++){
            inputs[i].checked=this.checked;
            //console.log(inputs[i].value);
        }
        //return vel;

    });

    // 注册事件
    /* che.onclick = function(){
         // this.checked  可以得到当前复选框的选中状态，如果是 true 就是选中，如果是 false 就是未选中
         for(var i=0; i< inputs.length; i++){
             inputs[i].checked = this.checked;
         }
     }*/
    // 2、下面的复选框要全部选中，上面的全选按钮才能够全部选中，给下面的所有复选框绑定事件，每次点击，都要循环查看下面下面所有的复选框是否有没选中的，如果有没选中的复选框，那么上面的全选按钮就不选中。
    /*for(var i = 0; i<inputs.length; i++){
        inputs[i].onclick = function(){
             // 设置一个变量来控制按钮是否全部选中
             var flag = true;
             // 每次点击下面的复选框都要检查下面的四个小按钮是否被全部选中。
             /!*for(var i =0; i<inputs.length; i++){
                  if(!inputs[i].checked){
                      flag = false;
                  }
             }*!/
             che.checked = flag;
        }
    }*/

</script>
<script>


</script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);

        //监听提交
        form.on('submit(add)', function updateCustomer() {
            $.post("order/updateT",$('#update_ticket').serialize(),function (obj) {
                var i=parseInt(obj);
                if(i>0){
                    alert("修改成功");
                    window.parent.location.reload();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }else {
                    alert("修改失败");
                }
            });

        });
    });

</script>
</body>
</html>